<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../lib/jquery-3.6.0.min.js"></script>
    <link rel="stylesheet" href="../lib/bootstrap-3.3.5-dist/css/bootstrap.min.css">
    <script src="../lib/bootstrap-3.3.5-dist/js/bootstrap.js"></script>
    <link rel="stylesheet" href="../lib/bootstrap-3.3.5-dist/js/bootstrap.min.js">
    <link rel="stylesheet" href="../font/iconfont.css">
    <link rel="stylesheet" href="../css/index.css">
    <link rel="stylesheet" href="../css/Dapartment.css">
    <link rel="stylesheet" href="../css/disease.css">
</head>

<body>
    <div class="container-fluid">
        <div class="kong11"></div>
        <div id="mulu">
            <div><span>首页</span>
                <span>/ </span>
                <span>医疗服务</span>
                <span>/</span><span>预约设置</span>
            </div>
            <h3>预约设置</h3>
        </div>
        <div class="row neirong" id="nr1">
            <div id="tdheight" class="col-md-10 col-md-offset-1 cha">
                <div class="keshi">医生列表</div>
                <div>
                    <button class="dis_tianjia dis_btn" onclick="app_tianjia()">
                        <span class="iconfont">&#xe889</span>
                        添加
                    </button>
                    <button class="dis_del dis_btn" onclick="dis_delbtn()">
                        <span class="iconfont">&#xe74b</span>
                        删除
                    </button>
                    <!-- <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal" data-whatever="@mdo" onclick="dis_delbtn()">
                        <span class="iconfont">&#xe74b</span>
                        删除
                    <tton> -->
                </div>
                <div class="row" id="neirong">
                    <div class="col-md-12">
                        <div class="clear">
                            <p class="iconfont">&#xe60a</p>
                            <p>已选择 <span id="xuanze"></span> 项，可以进行批量操作</p>
                        </div>
                    </div>
                </div>
                <table class="table">
                    <thead>
                        <tr>
                            <th>一级科室</th>
                            <th>日期</th>
                            <th>时间段</th>
                            <th>业务类型</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody id="mytbody">
                    </tbody>
                </table>
            </div>
        </div>
    </div>
    <!-- 底部 -->
    <div>
        <span class="foot1">大健康综合管理后台</span>
        <span class="foot2">版权所有:@大健康综合(集团)有限公司Meinian Onehealth Healthcare (Group)Co.</span>
        <span class="foot2">沪ICP备09017846号-3沪公网安备31010602006448号</span>
    </div>
    <!-- 批量删除模态框 -->
    <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                            aria-hidden="true">&times;</span>
                    </button>
                    <h4 class="modal-title" id="exampleModalLabel">你确认要删除这些数据信息吗</h4>
                </div>
                <div class="modal-body">
                    <form>
                        <div class="form-group">
                            <p>
                                删除后将无法恢复，你还要继续吗？
                            </p>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <div class="row">
                        <div class="col-md-2 col-md-offset-8">
                            <button type="button" class="btn-default motaidelbtn motaidelbtn dis_btn dis_tianjia"
                                data-dismiss="modal">取消</button>
                        </div>
                        <div class="col-md-2">
                            <button type="button"
                                class="btn-primary queding motaidelbtn motaidelbtn dis_btn dis_del">确定</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script src="../JavaScript/index.js"></script>
    <script src="../JavaScript/data.js"></script>
    <script src="../JavaScript/utils.js"></script>
    <script>
        let newdata = getmyData('about')
        let disabout = []
        if (newdata == null) {
            setmyData('about', about)
            newdata = getmyData('about')
        }
        let count = 0
        function showTable(data) {
            $('#mytbody').html('')
            $.each(data, (index, item) => {
                $('#mytbody').append(`
                <tr>
                    <td><input type="checkbox" name="" id="${item.id}"></td>
                    <td>${item.date}</td>
                    <td>${item.time}</td>
                    <td>${item.type}</td>
                    <td>
                        <div class="change" data-item='${JSON.stringify(item.erji)}'>编辑</div>
                        </td>
                </tr>
                `)
            })
        }
        showTable(newdata)
        mysepcil()
        function mysepcil() {
            for (let i = 0; i < newdata.length; i++) {
                if (newdata[i].sale == true) {
                    $('tbody input').eq(i).prop('checked', true)
                }
            }
        }
        for (let i = 0; i < newdata.length; i++) {
            if (newdata[i].sale == true) {
                count++
            }
        }
        $('#xuanze').text(count)
        $('tbody').on('click', 'input', function () {
            let n = parseInt($(this).attr('id'))
            for (let i = 0; i < newdata.length; i++) {
                if (n == newdata[i].id) {
                    // console.log(n)
                    if (newdata[i].sale == true) {
                        newdata[i].sale = false
                        count--
                    } else {
                        newdata[i].sale = true
                        count++
                        break
                    }
                }
            }
            $('#xuanze').text(count)
        })
        function dis_delbtn() {
            $('#exampleModal').modal('toggle')
        }
        $('.queding').click(function () {
            for (let i = 0; i < newdata.length; i++) {
                if (newdata[i].sale == true) {
                    count = 0
                    about.splice(i, 1)
                    // console.log(disease)
                    newdata.splice(i, 1)
                    i--
                    $('#xuanze').text(count)
                }
            }

            setmyData("about", newdata)
            // console.log(newdata);
            // querydata2 = []
            newdata = getmyData("about")
            // cutdata(newdata, querydata2, 3, 5, 2)
            // showTable(3, querydata2)
            showTable(newdata)
            $("#exampleModal.modal.fade.in").trigger("click")
        })
        $('#exampleModal').on('show.bs.modal', function (event) {
            var button = $(event.relatedTarget) // Button that triggered the modal
            var recipient = button.data('whatever')
            var modal = $(this)
            modal.find('.modal-title').text('你确认要删除这些数据信息吗')
            modal.find('.modal-body input').val(recipient)
        })
    </script>
</body>

</html>